package com.example.arithmeticleetcode.learnArithmetic;

import java.util.Objects;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-08-07 13:40
 **/
public class Person {

    private Integer age;

    private String name;

    public Person(Integer age, String name) {
        this.age = age;
        this.name = name;
    }

    public Person() {
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        System.out.println("Persion - finalize");
    }

    @Override
    public int hashCode() {

        return Objects.hash(age, name);
    }

    @Override
    public boolean equals(Object obj) {

        Person person = (Person) obj;
        return person.age == this.age;
    }
}
